// --------------------------------------------------------------------------------------------------------------------
// <copyright file="RoleWrapper.cs" company="AzureContrib (Open source library http://azurecontrib.codeplex.com)">
//   Microsoft Public License (Ms-PL)
// </copyright>
// <summary>
//   Exception for errors when handling Windows Azure Cloud Drives.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;

namespace AzureContrib.WindowsAzure.ServiceRuntime
{
	internal class RoleWrapper : IRole
	{
		private readonly Microsoft.WindowsAzure.ServiceRuntime.Role role;

		public RoleWrapper(Microsoft.WindowsAzure.ServiceRuntime.Role role)
		{
			this.role = role;
		}

		public string Name
		{
			get { return role.Name; }
		}

		public ReadOnlyCollection<IRoleInstance> Instances
		{
			get
			{
				IList<IRoleInstance> roleInstances = role.Instances
																								 .Select(ri => new RoleInstanceWrapper(ri))
																								 .Cast<IRoleInstance>()
																								 .ToList();
				return new ReadOnlyCollection<IRoleInstance>(roleInstances);
			}
		}
	}
}